/* GUI CONVERTED from reworki1.p (converter v1.75) Thu Oct  5 12:01:14 2000 */
/* reworki1.p - REPETITIVE                                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                         */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 03/08/95   BY: WUG *G0GR*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 10/25/99   BY: *N002* Bill Gates         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* REVISION: 9.1      LAST MODIFIED: 09/11/00   BY: *N0RQ* Mudit Mehta        */

/* REWORK TRANSACTION INPUT SUBPROGRAM                                        */

/*N002*/ {mfdeclre.i}
         {gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

/*N0RQ*
 * &SCOPED-DEFINE reworki1_p_1 "Rework"
 * /* MaxLen: Comment: */
 *N0RQ*/

/* ********** End Translatable Strings Definitions ********* */

/*N002*
 * def input param cumwo_lot as char.
 * def input param cumwo_op as int.
 * def output param undo_stat like mfc_logical no-undo.
 *N002*/

/*N002*/ define input parameter cumwo_lot as character.
/*N002*/ define input parameter cumwo_op as integer.
/*N002*/ define output parameter undo_stat like mfc_logical no-undo.

/*N04H*  {rewrsdef.i}                                                        */

         {retrform.i}

/*N002*  {mfdeclre.i} */

/*N002**
 * def var tot_units like op_qty_comp.
 * def var i as int.
 * def var j as int.
 * def var date_change as int.
 * def var elapse as dec format ">>>>>>>>.999".
 * def var last_op as log.
 * def var undostat like mfc_logical no-undo.
 * def var new_conv like conv.
 * def var input_que as log init yes.                                      /*G0GR*/
 * def var output_que as log init no.                                      /*G0GR*/
 * def shared var rsn_codes as char extent 10.
 * def shared var quantities like wr_qty_comp extent 10.
 * def shared var rework_rsn_codes as char extent 10.
 * def shared var rework_quantities like wr_qty_comp extent 10.
 *N002**/

/*N002*/ define variable tot_units like op_qty_comp.
/*N002*/ define variable i as integer.
/*N002*/ define variable j as integer.
/*N002*/ define variable date_change as integer.
/*N002*/ define variable elapse as decimal format ">>>>>>>>.999".
/*N002*/ define variable last_op like mfc_logical.
/*N002*/ define variable undostat like mfc_logical no-undo.
/*N002*/ define variable new_conv like conv.
/*N002*/ define variable input_que like mfc_logical initial yes.             /*G0GR*/
/*N002*/ define variable output_que like mfc_logical initial no.             /*G0GR*/
/*N002*/ define shared variable rsn_codes as character extent 10.
/*N002*/ define shared variable quantities like wr_qty_comp extent 10.
/*N002*/ define shared variable rework_rsn_codes as character extent 10.
/*N002*/ define shared variable rework_quantities like wr_qty_comp extent 10.

/*N002*/ define shared variable h_wiplottrace_procs as handle no-undo.
/*N002*/ define shared variable h_wiplottrace_funcs as handle no-undo.

/*N002*/ {wlfnc.i} /*FUNCTION FORWARD DECLARATIONS*/
/*N002*/ {wlcon.i}

/*N002*/ for first wo_mstr where wo_lot = cumwo_lot no-lock: end.

         find first wr_route where wr_lot = cumwo_lot and wr_op > cumwo_op
         no-lock no-error.

         last_op = not available wr_route.

         undo_stat = yes.

         do with frame rework1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

            {regetwcm.i &framename=rework1}

            do with frame rework1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


               set
                  dept
                  um
                  conv
                  qty_rwrk
                  rwrk_rsn_code
                  rwrk_multi_entry
/*N002*/          when  (not
/*N002*/                (is_wiplottrace_enabled()
/*N002*/             and is_operation_queue_lot_controlled(cumwo_lot, cumwo_op,
/*N002*/                                                REJECT_QUEUE)
/*N002*/                 ))
                  mod_issrc
                  act_run_hrs
                  earn_code
/*N002*/          to_op    when (not last_op)
/*N002*/          to_que   when (not last_op)
/*N002*           to_op    when not last_op  */
/*N002*           to_que   when not last_op  */
               editing:

                  global_lot = cumwo_lot.

                  if frame-field = "dept" then do:
                     {mfnp05.i dpt_mstr dpt_dept yes dpt_dept
                        "input frame rework1 dept"}
                     if recno <> ? then
                        display dpt_dept @ dept dpt_desc.
                  end.
                  else if frame-field = "earn_code" then do:
                     {mfnp05.i ea_mstr ea_earn yes ea_earn "input frame rework1
                         earn_code"}
                     if recno <> ? then
                        display ea_earn @ earn_code ea_desc.
                  end.
                  else if frame-field = "rwrk_rsn_code" then do:
                     {mfnp05.i rsn_ref rsn_type "rsn_type = ""rework""" rsn_code
                         "input frame rework1 rwrk_rsn_code"}
                     if recno <> ? then
                        display rsn_code @ rwrk_rsn_code.
                  end.
                  else if frame-field = "to_op" then do:
                     {mfnp05.i wr_route wr_lot
                         "wr_lot = cumwo_lot and wr_op >= op"
                          wr_op "input frame rework1 to_op"}
                     if recno <> ? then do:
                        display wr_op @ to_op wr_desc.
                     end.
                  end.
                  else do:
                     ststatus = stline[3].
                     status input ststatus.
                     readkey.
                     apply lastkey.
                  end.

               end.

               find dpt_mstr where dpt_dept = dept no-lock no-error.

               if not available dpt_mstr then do:
                  next-prompt dept.
                  {mfmsg.i 532 3}
                  undo, retry.
               end.

               display dpt_desc.

               find pt_mstr where pt_part = part no-lock.

               if um <> pt_um then do:
                  {gprun.i ""gpumcnv.p""
                   "(input um, input pt_um, input part, output new_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if new_conv = ? then do:
                     {mfmsg.i 33 2}
                  end.
                  else do:
                     if not frame rework1 conv entered then do:
                        conv = new_conv.
/*N002*                 disp conv. */
/*N002*/                display conv.
                     end.
                  end.
               end.

               if earn_code > "" then do:
                  find ea_mstr where ea_earn = earn_code no-lock no-error.

                  if not available ea_mstr then do:
                     {mfmsg.i 4025 3}
                     next-prompt earn_code.
                     undo , retry.
                  end.

                  display ea_desc.
               end.
               else
                  display " " @ ea_desc.

               find rsn_ref where rsn_code = rwrk_rsn_code
               and rsn_type = "rework" no-lock no-error.

               if not available rsn_ref and rwrk_rsn_code > "" then do:
                  {mfmsg.i 534 2}
               end.

               if not last_op then do:

                  find wr_route where wr_lot = cumwo_lot and wr_op = to_op
                  no-lock no-error.

                  if not available wr_route then do:
                     {mfmsg.i 106 3}
                     next-prompt to_op.
                     undo, retry.
                  end.

                  if to_op < op then do:
                     {mfmsg.i 5111 3}
                     next-prompt to_op.
                     undo, retry.
                  end.

/*N002*           disp wr_desc.  */
/*N002*/          display wr_desc.

                  /*G0GR ADDED FOLLOWING SECTION*/
                  if to_que = input_que and to_op = op then do:
                     {mfmsg.i 273 3}
                     next-prompt to_op.
                     undo, retry.
                  end.
                  /*G0GR END SECTION*/

               end.

/*N002*        disp start_run stop_run.  */
/*N002*/       display start_run stop_run.

               if act_run_hrs = 0 then do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

                  set start_run stop_run.

                  if start_run > "" and stop_run = "" then do:
                     {mfmsg.i 5102 3}
                     undo, retry.
                  end.

                  {mfctime.i start_run stop_run}
                  act_run_hrs = elapse.
                  display act_run_hrs.
               end.
/*GUI*/ if global-beam-me-up then undo, leave.


               if rwrk_multi_entry then do:
                  do i = 1 to 10:
                     rsn_codes[i] = rework_rsn_codes[i].
                     quantities[i] = rework_quantities[i].
                  end.

/*N0RQ*           {gprun.i ""resrqrin.p"" "(input ""rework"",
 *                 input "{&reworki1_p_1}", output undostat)"} */
/*N0RQ*/          {gprun.i ""resrqrin.p"" "(input ""rework"",
                     input getTermLabel(""REWORK"",35), output undostat)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if undostat then undo, retry.
                  qty_rwrk = 0.

                  do i = 1 to 10:
                     rework_rsn_codes[i] = rsn_codes[i].
                     rework_quantities[i] = quantities[i].
                     qty_rwrk = qty_rwrk + quantities[i].
                  end.

/*N002*           disp qty_rwrk with frame rework1. */
/*N002*/          display qty_rwrk with frame rework1.
               end.

            end.
/*GUI*/ if global-beam-me-up then undo, leave.


            undo_stat = no.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.

